package DataStructureAndAlgorithm.CSP.Day17;

import java.util.Scanner;
//链接：https://www.acwing.com/problem/content/description/3281/
public class AcWing_3278 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int N = 1010;
        boolean[] st = new boolean[N];
        int midCnt = 0;
        int allSum = 0;
        for (int k = 1; k <= n; k++){
            int m = in.nextInt();
            int sum = in.nextInt();
            for (int i = 1; i < m; i++){
                int temp = in.nextInt();
                if (temp <= 0){
                    sum += temp;//减去疏果的数量
                }else {
                    if (st[k]){
                        //已经将该树算入掉果的名单，只需更新sum即可
                        sum = temp;
                    }else {
                        //如果新的总数比原来小了，则说明落果了。需要更新
                        if (sum > temp){
                            midCnt++;
                            sum = temp;
                            st[k] = true;
                            //System.out.println(k);
                        }

                    }
                }
            }

            allSum += sum;
        }

        int tempCnt = 0;
        int conCnt = 0;
        for (int k = 1; k <= n; k++){
            if (st[k]){
                tempCnt++;
                if (tempCnt >= 3){
                    tempCnt--;
                    conCnt++;
                }
            }else{
                tempCnt = 0;
            }
        }
        //只有三棵树，但三棵树都落果的情况，组数为3组
        if (st[1] && st[n] && st[n - 1])conCnt++;
        if (st[1] && st[2] && st[n])conCnt++;
        System.out.println(allSum + " " + midCnt + " " + conCnt);
    }
}
